<?
 require("sks.inc.php");
 require("sks-status.inc.php");

 header("Content-type: text/plain");
 $servers = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache.serialized"));
 $serverarr = $servers->get_servers();
 
 $status_collection = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache_status_collection.serialized"));
 $servercolarr = $status_collection->get_servers();
 
 sort($serverarr);
 
 $iplist = array();
 $iplist3=array();
 
 foreach($serverarr as $server)
 {
  if($server->get_ipv6() === false) continue; 

  $ip=gethostbyname6($server->get_hostname());
  if(!in_array($ip,$iplist3) && !is_array($ip))
  {
   if(!$server->get_ipv6()) continue;
   if($servercolarr[$server->get_hostname()]['last_status']==1)
   {
    $iplist[$server->get_hostname()] =  "ipv6.pool AAAA ".$ip."\n";
    $iplist[$server->get_hostname()] .=  "pool AAAA ".$ip."\n";
   }
   $iplist3[] = $ip;
  }
 }
 
#print_r($iplist);

 if(count($iplist)>=10)
 {
  $iplist2 = array_rand($iplist,10);
 
  foreach($iplist2 as $line) 
  {
   echo $iplist[$line];
  }
 }
 else
 {
  foreach($iplist as $l)
  {
   echo $l;
  }
 }
?>
